import { _decorator, Component, director, Sprite, UITransform } from 'cc';
import { $planet_ClientAPI_poof$ } from './src/api/client.api';
const { ccclass, property } = _decorator;

@ccclass('LoadScene')
export class LoadScene extends Component {

	protected onLoad(): void {
		this.loadGameScene();
	}

    start() {
		this.adaptUI();
    }

	private adaptUI(){
		let ui_bg = this.node.getChildByName('background').getComponent(UITransform);
		let size_bg = ui_bg.getComponent(Sprite).spriteFrame.originalSize;
		let ratio = abd.$planet_size_poof$.$planet_exterRatio_poof$(size_bg, abd.$planet_size_poof$.$planet_canvasSize_poof$);
		ui_bg.setContentSize(size_bg.width * ratio, size_bg.height * ratio);
	}

	private async loadGameScene(){
		let type = await $planet_ClientAPI_poof$.$planet_GameType_poof$();

		let scene_name = type=='A' ? 'game' : 'main';

		director.preloadScene(scene_name, ()=>{
			director.loadScene(scene_name);
		});
	}
}

